package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Tap;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 开孔信息表
 */
public class TapVO extends BaseVO<Tap> {

    // 管道ID
    private String pipeLineName;
    // 开孔编号(自定义编号)
    private String tapNumber;
    // 绝对距离(m)
    private String mileage;
    // 相对最近参考点
    private String reference;
    // 相对最近参考点距离(m)
    private String referenceDistance;
    // 位置描述
    private String locationDescription;
    // 承压能力（Mpa）
    private String capacity;
    // 是否有冒管
    private String cappedind;
    // 流向
    private String flowDirection;
    // 是否有计量设备
    private String meteredind;
    // 主管道外径（mm）
    private String outsideDiameter;
    // 压力等级（MPa）
    private String pressureRating;
    // 是否为工厂预制
    private String premanufacturedind;
    // 开孔尺寸(mm)
    private String tapsize;
    // 壁厚(mm)
    private String wallthickness;
    // 开孔类型
    private String tapType;
    // 开孔方式
    private String tapPingmethod;
    //  开孔原因
    private String tapReason;
    // 开孔日期
    private String tappingDate;
    // 施工单位
    private String assemblyCompany;
    // 监理单位
    private String inspectingCompany;
    // 检测单位
    private String testingCompany;
    // 链接GIS结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getTapNumber() {
        return tapNumber;
    }

    public void setTapNumber(String tapNumber) {
        this.tapNumber = tapNumber;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReferenceDistance() {
        return referenceDistance;
    }

    public void setReferenceDistance(String referenceDistance) {
        this.referenceDistance = referenceDistance;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getCapacity() {
        return capacity;
    }

    public void setCapacity(String capacity) {
        this.capacity = capacity;
    }

    public String getCappedind() {
        return cappedind;
    }

    public void setCappedind(String cappedind) {
        this.cappedind = cappedind;
    }

    public String getFlowDirection() {
        return flowDirection;
    }

    public void setFlowDirection(String flowDirection) {
        this.flowDirection = flowDirection;
    }

    public String getMeteredind() {
        return meteredind;
    }

    public void setMeteredind(String meteredind) {
        this.meteredind = meteredind;
    }

    public String getOutsideDiameter() {
        return outsideDiameter;
    }

    public void setOutsideDiameter(String outsideDiameter) {
        this.outsideDiameter = outsideDiameter;
    }

    public String getPressureRating() {
        return pressureRating;
    }

    public void setPressureRating(String pressureRating) {
        this.pressureRating = pressureRating;
    }

    public String getPremanufacturedind() {
        return premanufacturedind;
    }

    public void setPremanufacturedind(String premanufacturedind) {
        this.premanufacturedind = premanufacturedind;
    }

    public String getTapsize() {
        return tapsize;
    }

    public void setTapsize(String tapsize) {
        this.tapsize = tapsize;
    }

    public String getWallthickness() {
        return wallthickness;
    }

    public void setWallthickness(String wallthickness) {
        this.wallthickness = wallthickness;
    }

    public String getTapType() {
        return tapType;
    }

    public void setTapType(String tapType) {
        this.tapType = tapType;
    }

    public String getTapPingmethod() {
        return tapPingmethod;
    }

    public void setTapPingmethod(String tapPingmethod) {
        this.tapPingmethod = tapPingmethod;
    }

    public String getTapReason() {
        return tapReason;
    }

    public void setTapReason(String tapReason) {
        this.tapReason = tapReason;
    }

    public String getTappingDate() {
        return tappingDate;
    }

    public void setTappingDate(String tappingDate) {
        this.tappingDate = tappingDate;
    }

    public String getAssemblyCompany() {
        return assemblyCompany;
    }

    public void setAssemblyCompany(String assemblyCompany) {
        this.assemblyCompany = assemblyCompany;
    }

    public String getInspectingCompany() {
        return inspectingCompany;
    }

    public void setInspectingCompany(String inspectingCompany) {
        this.inspectingCompany = inspectingCompany;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Tap domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道ID
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 开孔编号(自定义编号)
        this.tapNumber = domain.getTapNumber();
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 相对最近参考点
        this.reference = domain.getReference();
        // 相对最近参考点距离(m)
        this.referenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 承压能力（Mpa）
        this.capacity = NumberFormat.format(domain.getCapacity());
        // 是否有冒管
        this.cappedind = convert(domain.getCappedind());
        // 流向
        this.flowDirection = CodeUtil.getName(domain.getFlowDirection());
        // 是否有计量设备
        this.meteredind = convert(domain.getMeteredind());
        // 主管道外径（mm）
        this.outsideDiameter = CodeUtil.getName(domain.getOutsideDiameter());
        // 压力等级（MPa）
        this.pressureRating = NumberFormat.format(domain.getPressureRating());
        // 是否为工厂预制
        this.premanufacturedind = convert(domain.getPremanufacturedind());
        // 开孔尺寸(mm)
        this.tapsize = NumberFormat.format(domain.getTapsize());
        // 壁厚(mm)
        this.wallthickness = NumberFormat.format(domain.getWallthickness());
        // 开孔类型
        this.tapType = CodeUtil.getName(domain.getTapType());
        // 开孔方式
        this.tapPingmethod = domain.getTapPingmethod();
        //  开孔原因
        this.tapReason = domain.getTapReason();
        // 开孔日期
        this.tappingDate = DateFormat.format(domain.getTappingDate());
        // 施工单位
        this.assemblyCompany = domain.getAssemblyCompany();
        // 监理单位
        this.inspectingCompany = domain.getInspectingCompany();
        // 检测单位
        this.testingCompany = domain.getTestingCompany();
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<TapVO> fromDomainList(Page<Tap> domainList) {
        Page<TapVO> list = new Page<TapVO>();
        for (Tap tap : domainList) {
            TapVO tapVO = new TapVO();
            tapVO.fromDomain(tap);
            list.add(tapVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}